package com.ruoyi.restaurant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.restaurant.domain.SysHuiyuan;
import com.ruoyi.restaurant.service.ISysHuiyuanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员数据Controller
 * 
 * @author ruoyi
 * @date 2022-05-26
 */
@RestController
@RequestMapping("/huiyuan/show")
public class SysHuiyuanController extends BaseController
{
    @Autowired
    private ISysHuiyuanService sysHuiyuanService;

    /**
     * 查询会员数据列表
     */
    @PreAuthorize("@ss.hasPermi('huiyuan:show:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysHuiyuan sysHuiyuan)
    {
        startPage();
        List<SysHuiyuan> list = sysHuiyuanService.selectSysHuiyuanList(sysHuiyuan);
        return getDataTable(list);
    }

    /**
     * 导出会员数据列表
     */
    @PreAuthorize("@ss.hasPermi('huiyuan:show:export')")
    @Log(title = "会员数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysHuiyuan sysHuiyuan)
    {
        List<SysHuiyuan> list = sysHuiyuanService.selectSysHuiyuanList(sysHuiyuan);
        ExcelUtil<SysHuiyuan> util = new ExcelUtil<SysHuiyuan>(SysHuiyuan.class);
        util.exportExcel(response, list, "会员数据数据");
    }

    /**
     * 获取会员数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('huiyuan:show:query')")
    @GetMapping(value = "/{huiyuanId}")
    public AjaxResult getInfo(@PathVariable("huiyuanId") Integer huiyuanId)
    {
        return AjaxResult.success(sysHuiyuanService.selectSysHuiyuanByHuiyuanId(huiyuanId));
    }

    /**
     * 新增会员数据
     */
    @PreAuthorize("@ss.hasPermi('huiyuan:show:add')")
    @Log(title = "会员数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysHuiyuan sysHuiyuan)
    {
        return toAjax(sysHuiyuanService.insertSysHuiyuan(sysHuiyuan));
    }

    /**
     * 修改会员数据
     */
    @PreAuthorize("@ss.hasPermi('huiyuan:show:edit')")
    @Log(title = "会员数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysHuiyuan sysHuiyuan)
    {
        return toAjax(sysHuiyuanService.updateSysHuiyuan(sysHuiyuan));
    }

    /**
     * 删除会员数据
     */
    @PreAuthorize("@ss.hasPermi('huiyuan:show:remove')")
    @Log(title = "会员数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{huiyuanIds}")
    public AjaxResult remove(@PathVariable Integer[] huiyuanIds)
    {
        return toAjax(sysHuiyuanService.deleteSysHuiyuanByHuiyuanIds(huiyuanIds));
    }
}
